<%@ include file="common.jsp"%>
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<style type="text/css">
body {
	overflow-x: hidden;
	overflow-y: hidden;
	padding: 15px 15px 0 0;
}
</style>
</head>
<body>
	<form class="form-horizontal">
		<div class="form-group">
			<label class="col-sm-2 control-label">卡号：</label>
			<div class="col-sm-10">
				<input type="text" class="form-control" name="rid">
			</div>
		</div>
		<div class="form-group">
			<div class="col-sm-1 col-sm-offset-2">
				<button class="btn btn-default" type="button" onclick="add()">保存</button>
			</div>
			<div class="col-sm-1">
				<button class="btn btn-default" type="button" onclick="closeLayer()">返回</button>
			</div>
		</div>
	</form>
</body>
<script type="text/javascript">
	var $rid = $('input[name="rid"]');

	function add() {
		if (validate()) {
			var url = BaseUrl + 'rechargeCardAction/addCard.action';
			var option = {};
			option['rid'] = $rid.val();
			$.a(url, option, function(res) {
				console.log(res);
				if (res.result) {
					parent.load();
					parent.layer.msg('保存成功', {
						time : 2000
					});
					closeLayer();
				} else {
					parent.layer.msg(res.message, {
						time : 2000
					});
				}
			}, false);
		}
	}

	function validate() {
		if (isEmpty($rid.val())) {
			layer.msg('卡号不能为空', {time : 2000});
			$rid.focus();
			return false;
		}
		return true;
	}

	function closeLayer() {
		var index = parent.layer.getFrameIndex(window.name);
		parent.layer.close(index);
	}
</script>
</html>